<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // var str = "dfhs893409";
        // var reg = /^[0-9]+/;         //以数字开头
        // console.log(reg.test(str))   //false  
        // console.log(/\d+$/.test(str))//true  数字结尾
        // 去除前后尾空格
        var str ="     hello     ";
        var reg = /(^\s+)|(\s+$)/g;
        console.log(str.trim()) //hello
        console.log(str.replace(reg,"*")) //*hello*
    </script>
</body>
</html>